﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.utils;
using l1cs.server.datatables;

namespace l1cs.server.templates
{
    public class L1PetType
    {
        private int _baseNpcId;

        private L1Npc _baseNpcTemplate;

        private String _name;

        private int _itemIdForTaming;

        private IntRange _hpUpRange;

        private IntRange _mpUpRange;

        private int _npcIdForEvolving;

        private int[] _msgIds;

        private int _defyMsgId;

        public L1PetType( int baseNpcId, String name, int itemIdForTaming,
                IntRange hpUpRange, IntRange mpUpRange, int npcIdForEvolving,
                int[] msgIds, int defyMsgId )
        {
            _baseNpcId = baseNpcId;
            _baseNpcTemplate = NpcTable.getInstance().getTemplate( baseNpcId );
            _name = name;
            _itemIdForTaming = itemIdForTaming;
            _hpUpRange = hpUpRange;
            _mpUpRange = mpUpRange;
            _npcIdForEvolving = npcIdForEvolving;
            _msgIds = msgIds;
            _defyMsgId = defyMsgId;
        }

        public int getBaseNpcId()
        {
            return _baseNpcId;
        }

        public L1Npc getBaseNpcTemplate()
        {
            return _baseNpcTemplate;
        }

        public String getName()
        {
            return _name;
        }

        public int getItemIdForTaming()
        {
            return _itemIdForTaming;
        }

        public bool canTame()
        {
            return _itemIdForTaming != 0;
        }

        public IntRange getHpUpRange()
        {
            return _hpUpRange;
        }

        public IntRange getMpUpRange()
        {
            return _mpUpRange;
        }

        public int getNpcIdForEvolving()
        {
            return _npcIdForEvolving;
        }

        public bool canEvolve()
        {
            return _npcIdForEvolving != 0;
        }

        public int getMessageId( int num )
        {
            if ( num == 0 )
            {
                return 0;
            }
            return _msgIds[num - 1];
        }

        public static int getMessageNumber( int level )
        {
            if ( 50 <= level )
            {
                return 5;
            }
            if ( 48 <= level )
            {
                return 4;
            }
            if ( 36 <= level )
            {
                return 3;
            }
            if ( 24 <= level )
            {
                return 2;
            }
            if ( 12 <= level )
            {
                return 1;
            }
            return 0;
        }

        public int getDefyMessageId()
        {
            return _defyMsgId;
        }
    }
}
